<?php

class Businesses extends HTech_Db_Table
{
    protected $_name    = 'view_businesses';
    protected $_primary = 'BusinessId';
    
    protected $_referenceMap    = array(
        'Clients' => array(
            'columns'           => array('ClientId'),
            'refTableClass'     => 'Clients',
            'refColumns'        => array('ClientId')
        )
    );

    protected function _setGridMetadata()
    {
        switch($this->_name) {
            case '_log_businesses':
                $this->_gridMetadata['title'] = $this->translate("Businesses' Log");
                $this->_gridMetadata['params'] = array('BusinessId');
                $this->_gridMetadata['onClick'] = 'admin.business.view';
                $this->_gridMetadata['headers'] = array
                    (
                        array('BusinessId',     100, $this->translate("BusinessId"),     'Number'),
                        array('LastEditDate',   150, $this->translate("LastEditDate"),   'DateTime', 'Date'),
                        array('LastEditUserId', 150, $this->translate("LastEditUserId"), 'Number'),
                        array('TypeId',         100, $this->translate("TypeId"),         'Number'),
                        array('ClientId',       100, $this->translate("ClientId"),       'Number'),
                        array('GovCode',        150, $this->translate("GovCode"),        'String'),
                        array('Name',           300, $this->translate("Name"),           'String'),
                        array('Status',         100, $this->translate("Status"),         'String'),
                        array('Description',    700, $this->translate("Description"),    'String')
                    );
                break;
            default:
                $this->_gridMetadata['title'] = $this->translate("Businesses");
                $this->_gridMetadata['params'] = array('Type','Activity');
                $this->_gridMetadata['onClick'] = 'admin.business.view';
                $this->_gridMetadata['headers'] = array
                    (
                        array('BusinessId',         50, $this->translate("id"),                 'Number'),
                        array('GovCode',           150, $this->translate("Business gov. code"), 'String'),
                        array('Activity',           80, $this->translate("Activity"),           'String'),
                        array('Type',              200, $this->translate("Type"),               'String'),
                        array('Name',              250, $this->translate("Business name"),      'String'),
                        array('ClientFullName',    250, $this->translate("Client name"),        'String'),
                        array('LocationShortName', 100, $this->translate("Branch"),             'String'),
                        array('OfficerUsername',   100, $this->translate("Officer"),            'String'),
                        array('Status',             80, $this->translate("Status"),             'String'),
                        array('Description',       350, $this->translate("Description"),        'String')
                    );
        }
        return $this;
    }
   
}